package org.example.springboot.service;

import jakarta.annotation.Resource;
import org.example.springboot.entity.Comment;
import org.example.springboot.mapper.CommentMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService {
    @Resource
    private CommentMapper commentMapper;

    public void save(Comment comment) {
        // 存在评论内容不能为空的逻辑
        if (comment.getComment() == null || comment.getComment().trim().isEmpty()) {
            throw new IllegalArgumentException("评论内容不能为空");
        }
        System.out.println("评论保存到数据库中");
        commentMapper.save(comment);
    }

    public List<Comment> select(int vedioId) {
        return commentMapper.select(vedioId);
    }
}
